<template>
  <!-- 柱状图 -->
  <el-card style="height: 280px">
    <div style="height: 280px" ref="barEcharts">
      {{ initBarEcharts() }}
    </div>
  </el-card>
</template>
<script>
import * as echarts from "echarts";
export default {
	methods: {
		//柱状图
  initBarEcharts() {
    // 新建一个promise对象
    let p = new Promise((resolve) => {
      resolve();
    });
    //然后异步执行echarts的初始化函数
    p.then(() => {
      //	此dom为echarts图标展示dom
      let myChart = echarts.init(this.$refs.barEcharts);
      let option = {
        title: {
          text: "收益表",
        },
        tooltip: {},
        legend: {
          data: ["今日收益", "昨日收益"],
        },
        xAxis: {
          data: ["公司1", "公司2", "公司3", "公司4", "公司5", "公司6"],
        },
        yAxis: {},
        series: [
          {
            name: "今日收益",
            type: "bar",
            data: [5, 20, 36, 10, 10, 13],
          },
          {
            name: "昨日收益",
            type: "bar",
            data: [10, 18, 34, 8, 12, 14],
          },
        ],
      };
      // 使用刚指定的配置项和数据显示图表。
      myChart.setOption(option);
    });
  },
	}
};
</script>